package com.zsrt.java.day20161227.wrl.homework.demo03;

import org.junit.Test;

/**
 * 买码  1~49
 * @author Administrator
 */
public class Lottery {
	
	/**
	 * 已知：购买的号码
	 * 求：跟随机数是否相等
	 * 		相等：中奖
	 * 		不等：不中奖
	 */
	@Test
	public void lottery01(){
		int num = 49;
		int index = 1;
		while(index <= 100){
			int ran = (int)(Math.random()*49+1);
			if(num == ran){
				System.out.println("中奖了，特码是："+ran);
			}else{
				System.out.println("很遗憾没中奖！特码是："+ran);
			}
			index++;
		}
	}
	
	public static void lottery02(int num){
		int ran = (int)(Math.random()*49+1);
		if(num == ran){
			System.out.println("中奖了，特码是："+ran);
		}else{
			System.out.println("很遗憾没中奖！特码是："+ran);
		}
	}
	
	public static boolean lottery03(int num){
		int ran = (int)(Math.random()*49+1);
		if(num == ran){
			return true;
		}else{
			System.out.println("特码是："+ran);
			return false;
		}
	}

}
